package com.learning.demos.jvmgc;

import java.util.Random;

/**
 * @author adolphw
 *
 * -Xmx10m -Xms10m
 * 堆空间不足
 *
 * Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
 */
public class OOMJavaHeapSpaceDemo {

    public static void main(String[] args) {
//        byte[] bytes = new byte[80 * 1024 * 1024];
        String str = "java heap space";

        while (true) {
            str += str + new Random().nextInt(111111) + new Random().nextInt(222222);
            str.intern();
        }
    }
}
